<?php

namespace app\adminapi\validate;

use app\common\validate\BaseValidate;

class SysConfigValidate extends BaseValidate
{
    protected $rule = [
        'pageNo' => 'regex:/^([1-9]\d*)$/',
        'pageSize' => ['regex'=>'/^(-1|[1-9]\d*)$/'],
        'id' => 'require|number',
        'sysConfigId' => 'require|number',
        'configName' => 'require',
        'configKey' => 'require|array',
        'configValue' => 'require'
    ];

    protected $message = [
        'pageNo.regex' => '分页页码只能是数字',
        'pageSize.regex' => '分页页大小只能是数字',
        'sysConfigId|id.require' => '参数不完整',
        'sysConfigId$|id.number' => '参数配置数据ID类型错误',
        'configName.require' => '请输入参数名称',
        'configKey.require' => '请输入参数键名',
        'configValue.require' => '请输入参数值'
    ];

    protected $scene = [
        'list' => ['pageNo', 'pageSize'],
        'insert' => ['configName', ['configKey' => 'require'], 'configValue'],
        'delete' => ['sysConfigId'],
        'query' => ['sysConfigId'],
        'update' => ['id', 'configName', ['configKey' => 'require'], 'configValue'],
        'listByConfigKey' => ['configKey']
    ];
}